home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / linux / tools / amiga / gzip-1.1.2.lha / gzip-1.1.2 / add.c next >
Encoding:
C/C++ Source or Header  |  1993-05-28  |  851 b   |  30 lines

  1. /* add.c -- simple filter for 8 bit images or any 8 bit "smooth" data
  2.  * Written by Arthur David Olson <ado@elsie.nci.nih.gov>
  3.  *
  4.  * add is the reverse filter of sub (see sub.c). It simply reads on stdin
  5.  * differences between successive bytes and writes to stdout the raw bytes.
  6.  * sub can improve compression of 8 bit images or any 8 bit "smooth" data.
  7.  * For compression, use:
  8.  *   sub < raw_data | gzip > data.sub.gz
  9.  * For decompression, use:
  10.  *   gunzip < data.sub.gz | add > raw_data
  11.  *
  12.  * This program can easily be extended to handle 24 bit images, or 16 bit
  13.  * sound samples, or sequences of slowly varying floating point numbers.
  14.  */
  15.  
  16. #include "stdio.h"
  17.  
  18. main()
  19. {
  20.     int    c;
  21.     int    prevc = 0;
  22.  
  23.     while ((c = getchar()) != EOF) {
  24.     prevc += c;
  25.     (void) putchar(prevc & 0xff);
  26.     }
  27.     exit(0);
  28.     return 0; /* just to avoid warnings */
  29. }
  30.